function t(t, a, e) {
    return a in t ? Object.defineProperty(t, a, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[a] = e, t;
}

var a = require("../../utils/api.js"), e = require("../../wxParse/wxParse.js"), o = getApp();

Page({
    data: {
        static: !0,
        quesInfo: [],
        sysHeight: o.globalData.windowHeight
    },
    onLoad: function(t) {
        var e = this;
        console.log(1), a.GetContentArticle({
            openid: o.globalData.openid,
            cid: t.id
        }).then(function(a) {
            if (console.log(a), 0 == a.errno) if (a.data.length < 20 && a.data.length > 0) {
                for (o = 0; o < a.data.length; o++) a.data[o].rotate = !1, a.data[o].static = !0;
                e.setData({
                    quesInfo: a.data,
                    page: 0,
                    cid: t.id
                });
            } else if (0 == a.data.length) e.setData({
                showNo: !0,
                page: 0
            }); else {
                for (var o = 0; o < a.data.length; o++) a.data[o].rotate = !1, a.data[o].static = !0;
                e.setData({
                    quesInfo: a.data,
                    page: 2,
                    cid: t.id
                }), console.log(e.data.quesInfo);
            } else e.setData({
                showNo: !0,
                page: 0
            });
        });
    },
    showAns: function(a) {
        var o = this, s = a.currentTarget.dataset.index, n = a.currentTarget.dataset.id, i = "quesInfo[" + s + "].static", r = "quesInfo[" + s + "].rotate", d = o.data.quesInfo[s].static;
        o.setData({
            showAnsewr: !0
        }), setTimeout(function() {
            o.setData({
                showAnsewr: !1
            });
        }, 500);
        for (var l = 0; l < o.data.quesInfo.length; l++) if (!o.data.quesInfo[l].static) {
            var u, c = "quesInfo[" + l + "].static", f = "quesInfo[" + l + "].rotate";
            o.setData((u = {}, t(u, c, !0), t(u, f, !1), u));
        }
        if (e.wxParse("article", "html", o.data.quesInfo[s].body, o, 5), setTimeout(function() {
            o.setData({
                curQu: n
            });
        }, 200), d) {
            var g;
            o.setData((g = {}, t(g, r, !0), t(g, i, !1), g));
        } else o.setData(t({}, r, !1)), setTimeout(function() {
            o.setData(t({}, i, !0));
        }, 200);
    },
    scrolltolower: function() {
        var t = this, e = t.data.page, s = t.data.quesInfo, n = t.data.cid;
        console.log(e), !t.data.showAnsewr && e && (console.log(333), a.GetContentArticle({
            openid: o.globalData.openid,
            cid: n,
            page: e
        }).then(function(a) {
            console.log(a), a.data.length < 20 ? e = 0 : e += 1;
            for (var o = 0; o < a.data.length; o++) a.data[o].rotate = !1, a.data[o].static = !0, 
            s.push(a.data[o]);
            t.setData({
                quesInfo: s,
                page: e
            }), console.log(t.data.quesInfo);
        }));
    }
});